var ApiSite = "http://localhost:8989/feign/";
var ACT = {
    login: 'user/login',
    reg: 'user/register',
    vcode: 'user/getvcode',
    alldevice: 'device/alldevice',
    adddevice: 'device/add',
    controldevice: 'device/control',
    update: 'device/update',
    deletedevice: 'device/delete'
};
var WEEKDAY = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期天'];
var UTCTIME = ['UTC+0', 'UTC+1', 'UTC+2', 'UTC+3', 'UTC+4', 'UTC+5', 'UTC+6', 'UTC+7', '北京', 'UTC+9', 'UTC+10',
    'UTC+11', 'UTC+12', 'UTC+13', 'UTC+14'
];
var CONTROL_URL = {
    Hub: 'hub.html',
    Outlet: 'outlet.html',
    Switch: 'switch.html',
    THSSensor: 'THSSensor.html',
    InfraredForward: 'InfraredForward.html',
    AccessController: 'AccessController.html',
    EmergentBtn: 'EmergentBtn.html',
    DoorSensor: 'DoorSensor.html'
}

Vue.component('myfooter',{
  props:{
	  at1:{default:""},
	  at2:{default:""},
	  at3:{default:""},
	  at4:{default:""}
  },
  template: '<nav class="mui-bar mui-bar-tab">\
            <a onclick="openPage(\'home.html\',\'home\')" :class="\'mui-tab-item \'+at1">\
                <span class="mui-icon mui-icon-home"></span>\
                <span class="mui-tab-label">首页</span>\
            </a>\
            <a onclick="openPage(\'area.html\',\'area\')"  :class="\'mui-tab-item \'+at2">\
                <span class="mui-icon mui-icon-spinner"></span>\
                <span class="mui-tab-label">区域</span>\
            </a>\
            <a onclick="openPage(\'device.html\',\'device\')"  :class="\'mui-tab-item \'+at3">\
                <span class="mui-icon mui-icon-extra mui-icon-extra-computer"></span>\
                <span class="mui-tab-label">设备</span>\
            </a>\
            <a onclick="openPage(\'smart.html\',\'smart\')"  :class="\'mui-tab-item \'+at4">\
                <span class="mui-icon mui-icon-extra mui-icon-extra-university"></span>\
                <span class="mui-tab-label">智能</span>\
            </a>\
        </nav>'
});

function ApiPost(action, jd, callback) {
    //console.log(jd);
    var param = {};
    param.token = localStorage.getItem("auth_token");
    param.json = JSON.stringify(jd);
    //console.log(param);
    mui.post(ApiSite + action, param, callback, 'json');
}

function GetGuid() {
    function S4() {
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
    }
    return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
}

function formatDate(now) {
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var date = now.getDate();
    var hour = now.getHours();
    var minute = now.getMinutes();
    var second = now.getSeconds();
    return year + "-" + getFullStr(month) + "-" + getFullStr(date) + " " + getFullStr(hour) + ":" + getFullStr(minute) +
        ":" + getFullStr(second);
}

function getFullStr(str) {
    str = str + "";
    if (str.length < 2) str = "0" + str;
    return str;
}


function openPage(xurl, xid) {
    mui.openWindow({
        url: xurl,
        id: xid
    });
}

function InitAPP() {
    var user = JSON.parse(localStorage.getItem("user"));
    console.log(user);
    var cururl = window.location.pathname.toLowerCase();
    //if (user == null && cururl.indexOf("index.html") == -1 && cururl.indexOf("reg.html") == -1) {
    //     if (user != null) {
    //         mui.openWindow({
    //             url: 'home.html',
    //             id: 'home'
    //         });
    //     }
}

InitAPP();
